package com.transaction.common.base;

/**
 * @ClassName ResultVo
 * 描述 :
 * @Author weijunjie
 * @Date 2020/7/30 17:41
 */
@SuppressWarnings("all")
public class ResultVo<T> {

    /** 状态码 .*/
    private Integer code;

    /** 消息 .*/
    private String msg;

    /** 具体值 .*/
    private Object data;

    public ResultVo() {

    }

    public ResultVo(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultVo(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultVo(Object data) {
        this.code = 200;
        this.msg = "OK";
        this.data = data;
    }

    public static ResultVo ok(Object data) {
        return new ResultVo(data);
    }

    public static ResultVo ok() {
        return new ResultVo(null);
    }

    public static ResultVo errorMsg(String msg) {
        return new ResultVo(500, msg, null);
    }

    public static ResultVo errorMap(Object data) {
        return new ResultVo(501, "error", data);
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
